<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="format-detection" content="email=no" />
    <meta name="format-detection" content="address=no" />
    <meta name="format-detection" content="date=no" />
    <title>第三方账号</title>
    <link href="../../css/api.css" rel="stylesheet" type="text/css">
    <link href="../../css/aui.css" rel="stylesheet" type="text/css">
    <link href="../../css/index.css" rel="stylesheet" type="text/css">
    <link href="../../css/public_win.css" rel="stylesheet" type="text/css">
    <link href="../../css/public.css" rel="stylesheet" type="text/css">
    <style>
        /*html,
        body {
            height: 100%;
            background: rgba(0, 0, 0, 0)
        }*/
    </style>
</head>

<body>
    <div class="vueApp" v-cloak>
        <div v-if="isLoad">
            <div class="space"></div>
            <div class="public_list">
                <div class="public_item" tapmode @click="fnSetThird(thirdInfo.isBingWinXin,'1')">
                    <span class="public_item_left">微信</span>
                    <span :class="thirdInfo.isBingWinXin=='0'?'public_item_content font_gray':'public_item_content'" v-text="thirdInfo.isBingWinXin=='0'?'未绑定':thirdInfo.weixinNickname"></span>
                    <img class="public_item_right_img" src="../../image/mine/go_page.png" alt="">
                </div>
                <div class="public_item" tapmode @click="fnSetThird(thirdInfo.isBingQQ,'2')">
                    <span class="public_item_left">QQ</span>
                    <span :class="thirdInfo.isBingQQ=='0'?'public_item_content font_gray':'public_item_content'" v-text="thirdInfo.isBingQQ=='0'?'未绑定':thirdInfo.qqNickname"></span>
                    <img class="public_item_right_img" src="../../image/mine/go_page.png" alt="">
                </div>
                <div class="public_item" tapmode @click="fnSetThird(thirdInfo.isBingWeiBo,'3')">
                    <span class="public_item_left">微博</span>
                    <span :class="thirdInfo.isBingWeiBo=='0'?'public_item_content font_gray':'public_item_content'" v-text="thirdInfo.isBingWeiBo=='0'?'未绑定':thirdInfo.weiboNickname"></span>
                    <img class="public_item_right_img" src="../../image/mine/go_page.png" alt="">
                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-font.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-login.js"></script>
<script type="text/javascript" src="../../script/service/service-verify.js"></script>
<script type="text/javascript" src="../../script/service/service-login.js"></script>
<script type="text/javascript">
    var $S, USER;
    var vm;
    apiready = function() {
        $S = SERVICE();
        USER = USER();
        fnInit();
        setTimeout(function() {
            fnSetPlayFrmFront();
        }, 300);

        fnInitPage();
    }

    function fnInit() {
        vm = new Vue({
            el: ".vueApp",
            data: {
                isLoad: false,
                thirdInfo: "",
            },
            methods: {

            }
        })
    }

    function fnInitPage() {
        $S.ShowProgress();
        $S.POST("newAddInterface/appUserBindThird", "", function(ret, err) {
            if (ret && ret.status) {
                vm.thirdInfo = ret.data;
                // "weiboNickname":"","weixinNickname":"","isBingWinXin":"0","isBingQQ":"0","isBingWeiBo":"0","qqNickname":""
            }
            vm.isLoad = true;
            $S.CloseProgress();
        })
    }

    function fnSetThird(isBind, type) {
        if (isBind == '0') {
            fnBindThird(type);
        } else {
            var param = {
                alertConfirmFn: "fnBindThird('" + type + "')",
                alertType: type * 1 + 6,
            }
            fnOpenAlert(param);
        }
    }

    function fnBindThird(key) { //key 1:微信登录; 2:QQ登录; 3:微博登录
        fnLoginType(key, function(_param, ret1, err1) {
            console.log(JSON.stringify(_param));
            console.log(JSON.stringify(ret1))
            console.log(JSON.stringify(ret1.info))
            console.log(JSON.stringify(err1));
            var _nickName;
            if (key == "1") { //微信登录
                // alert(JSON.stringify(ret1))
                _nickName = ret1.nickname;
                // _pData.avatar = ret1.headimgurl;
            } else if (key == "2") { //qq登录
                _nickName = JSON.parse(ret1.info).nickname;
                // _pData.avatar = JSON.parse(ret1.info).figureurl_qq_1;
            } else if (key == "3") { //微博登录
                _nickName = ret1.userInfo.screen_name;
                // _pData.avatar = ret1.userInfo.profile_image_url;
            }
            // console.log(JSON.stringify(_pData))
            //用于判断第三方是否绑定过手机号
            $S.ShowProgress();
            var postData = {
                "thirdId": _param.openId,
                "thirdKind": key,
                "thirdNickName": _nickName
            };
            $S.POST("newAddInterface/findThirdUser", postData, function(ret, err) {
                if (ret && ret.status == "200") {
                    fnToast("更换成功");
                    fnInitPage();
                }
                $S.CloseProgress();
            })

        })
    }
</script>

</html>
